load("//tools/build_defs/android:fb_xplat_cxx_library.bzl", "fb_xplat_cxx_library")
load("//tools/build_defs/oss:profilo_defs.bzl", "profilo_path")

APP_SPECIFIC_IS_ASSET_FLAG = {
    "default": True,
    "instagram": True,
}

fb_xplat_cxx_library(
    name = "external_api",
    srcs = [
        "ExternalApi.cpp",
    ],
    header_namespace = "profilo",
    exported_headers = [
        "ExternalApi.h",
    ],
    can_be_asset = APP_SPECIFIC_IS_ASSET_FLAG.get(read_config("fbandroid", "app_mode", "default")),
    force_static = True,
    link_style = "shared",
    preferred_linkage = "static",
    supported_platforms_regex = "^android-(arm|armv7|arm64|x86|x86_64)$",
    visibility = [
        "PUBLIC",
    ],
    deps = [
        ":external_api_glue",
    ],
)

fb_xplat_cxx_library(
    name = "external_api_header",
    header_namespace = "profilo",
    exported_headers = ["ExternalApi.h"],
    force_static = True,
    visibility = [
        profilo_path("..."),
    ],
)

fb_xplat_cxx_library(
    name = "external_api_glue",
    srcs = [
        "ExternalApiGlue.cpp",
    ],
    header_namespace = "profilo",
    exported_headers = [
        "ExternalApiGlue.h",
    ],
    can_be_asset = APP_SPECIFIC_IS_ASSET_FLAG.get(read_config("fbandroid", "app_mode", "default")),
    link_style = "shared",
    soname = "libprofiloextapi.$(ext)",
    supported_platforms_regex = "^android-(arm|armv7|arm64|x86|x86_64)$",
    visibility = [
        profilo_path("..."),
    ],
)

fb_xplat_cxx_library(
    name = "external_api_impl",
    srcs = [
        "ExternalApiImpl.cpp",
    ],
    allow_jni_merging = False,
    force_static = True,
    visibility = [
        profilo_path("..."),
    ],
    deps = [
        ":external_api_glue",
        profilo_path("cpp:constants"),
        profilo_path("cpp:providers"),
        profilo_path("cpp/profiler:external_tracer_manager"),
        profilo_path("cpp/logger:logger"),
        profilo_path("deps/fbjni:fbjni"),
    ],
)
